/**
Copyright 2011 Patrick Devaney

Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at

http://www.apache.org/licenses/LICENSE-2.0

Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

#include <iostream>
#include <string.h>
#include <math.h>
#define _USE_MATH_DEFINES
using namespace std;

/*
File purpose:
main.cpp includes this, and this function seamlessly performs
I/O and calculations.
*/

int volume(void) {
// As I've done before, I use i as a loop so the program doesn't crash if
// one enters something not on the menu or the feature in question isn't implemented
int i;
// This takes the input of which option the user chooses
string input;
i = 0;
while(i < 1) {
cout << "Do you want to calculate:" << endl
<< "1 - The volume of a cube" << endl << "2 - The volume of a triangular prism" << endl
<< "3 - The volume of a parallelogram prism" << endl << "4 - The volume of a trapezoidal prism" << endl
<< "5 - The volume of a triangular prism" << endl;
cin >> input;
if(input == "1") {
cout << "What is the length?" << endl;
long double side;
cin >> side;
side = side * side * side;
cout << "The volume of the cube is:" << endl << side << endl;
i++;
}
else if(input == "2") {
cout << "What is the length of the prism?" << endl;
long double length, width, height, volume;
cin >> length;
cout << "What is the width of the prism?" << endl;
cin >> width;
cout << "What is the height of the prism?" << endl;
cin >> height;
	if(length == width && width == height) {
	cout << "That's a cube! Use option 1 next time, and save yourself the effort of " << endl
	<< "entering the same number thrice!" << endl;
	}
volume = length * width * height;
cout << "The volume of the prism is:" << endl << volume << endl;
i++;
}

else if(input == "3") {
long double area, volume, base, height, length;
cout << "First we need the area of one end of the prism" << endl;
cout << "What is the base?" << endl;
cin >> base;
cout << "What is the height?" << endl;
cin >> height;
cout << "Excellent, now how long is the prism?" << endl;
cin >> length;
area = base * height;
volume = area * length;
cout << "The volume of the parallelogram prism is:" << endl << volume << endl;
i++;
}

else if(input == "4") {
long double b1, b2, h, l, area, volume;
cout << "First we need the area of one end of the prism" << endl;
cout << "What's the first base?" << endl;
cin >> b1;
cout << "What's the second base?" << endl;
cin >> b2;
cout << "What's the height?";
cin >> h;
cout << "Excellent, now how long is the prism?" << endl;
cin >> l;
h = h / 2;
area = b1 + b2;
area = h * area;
volume = area * l;
cout << "The volume of the prism is:" << endl << volume << endl;
i++;
}

else if(input == "5") {
long double b, h, l, area, volume;
cout << "First we need the area of one end of the prism" << endl;
cout << "What's the base?" << endl;
cin >> b;
cout << "What's the height?" << endl;
cin >> h;
cout << "Excellent, now how long is the prism?" << endl;
cin >> l;
area = b * h;
area = area / 2;
volume = area * l;
cout << "The volume of the prism is:" << endl << volume << endl;
i++;
}

// End of the while
}
// End of the function
}